package com.entertainment.ticketing.controller;

import com.entertainment.ticketing.dto.TicketInfoDTO;
import com.entertainment.ticketing.service.TicketService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/events/{eventId}/tickets")
public class TicketController {
    private final TicketService ticketService;

    public TicketController(TicketService ticketService) {
        this.ticketService = ticketService;
    }

    @GetMapping
    public ResponseEntity<List<TicketInfoDTO>> listTickets(
            @PathVariable("eventId") Long eventId,
            @RequestParam(value = "status", required = false) Byte status
    ) {
        return ResponseEntity.ok(ticketService.listByEvent(eventId, status));
    }
}